import SecondChoose from '@/views/extractThing/secondChoose.vue';
import lastChooseCard from '@/views/extractThing/lastChooseCard.vue';
import lastChooseBallot from '@/views/extractThing/lastChooseBallot.vue';
import threeChoose from '@/views/extractThing/threeChoose.vue';
import normalComp from './normalComp.vue';
import type { Component } from 'vue';

// 创造一个新的抽签
export const getNextComponent = (data: any, key: string): Component => {
  console.log(data,'data===');
  // 如果是赛制
  if (key === 'gameMode') {
    return SecondChoose
  }
  if (key === 'extractMode') {
    return threeChoose
  }
  if (key === 'options' && data instanceof Object) {
    console.log(data);
    if (data.extractMode === 'Card') {
        return lastChooseCard;
    } else {
      return lastChooseBallot;
    }
  }
  return normalComp
}

// 洗牌函数
export function shuffleArrayInPlace<T>(array: T[]): T[] {
  for (let i = array.length - 1; i > 0; i--) {
      const j = Math.floor(Math.random() * (i + 1));
      [array[i], array[j]] = [array[j], array[i]];
  }
  return array;
}